<?php
namespace app\api\controller\supplier;
use app\api\base\RestfulBase;
use app\modules\supplier\logic\ShopGoodsLogic;
class GoodsCate extends RestfulBase
{
    protected $logic;
    protected function _initialize()
    {

        $this->logic = new ShopGoodsLogic();

    }

    /**
     * 获取分类信息
     * @return Response
     */
    public function index(){
        if ($this->request->isPost()){
              $cate_id = $this->getParams('cate_id',0,'trim,strip_tags');
              $data = $this->logic->getCate($cate_id);
              if(is_array($data)){
                  return $this->apiSuccess($data);
              }else{
                  return $this->apiError($this->logic->getError());
              }
        }else{
            return $this->apiError('无效请求');
        }
    }

    /**
     * 获取全部分类信息
     * @return Response
     */
    public function all_index(){
        if ($this->request->isPost()){
            $data = $this->logic->getCateAll();
            if(is_array($data)){
                return $this->apiSuccess($data);
            }else{
                return $this->apiError($this->logic->getError());
            }
        }else{
            return $this->apiError('无效请求');
        }
    }


}